<?php

namespace app\admin\model;

use think\Model;


class Goods extends Model
{

    

    

    // 表名
    protected $name = 'goods';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'is_show_text'
    ];
    

    
    public function getIsShowList()
    {
        return ['0' => __('Is_show 0'), '1' => __('Is_show 1')];
    }
    public function getIsHomeList()
    {
        return ['0' => __('Is_Home 0'), '1' => __('Is_Home 1')];
    }

    public function getIsShowTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_show']) ? $data['is_show'] : '');
        $list = $this->getIsShowList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getIsHomeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_home']) ? $data['is_home'] : '');
        $list = $this->getIsHomeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function goodscategory()
    {
        return $this->belongsTo('GoodsCategory', 'goods_category_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function author()
    {
        return $this->belongsTo('Author', 'author_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function network()
    {
        return $this->belongsTo('Network', 'network_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
